package com.ty.user.starter.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ty.user.starter.entity.UserRole;
import com.ty.user.starter.entity.vo.RoleVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户-角色表 Mapper 接口
 * </p>
 *
 * @author minku
 * @since 2021-10-17
 */
public interface UserRoleMapper extends BaseMapper<UserRole> {
    /**
     * 查询用户的角色信息
     * @param userId 用户id
     * @return 用户信息
     */
    @Select("SELECT b.id,b.`name`,b.bus_code,b.state FROM ty_user_role a INNER JOIN ty_role b ON a.role_id = b.id AND b.state = 1 WHERE a.user_id = #{userId}")
    List<RoleVo> findByUserId(@Param("userId") long userId);
}
